/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* TreckGUI.java
*
* Created on 11.11.2011, 22:26:47
*/
package edu.gui;
import edu.Esel;
import edu.Treck;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Vector;
/**
*
* @author Fonduee
*/
public class TreckGUI extends javax.swing.JFrame {
/** Creates new form TreckGUI */
public TreckGUI() {
_EselWelt.add(new Esel(50, "Heinz", "Hamburg"));
_EselWelt.add(new Esel(35, "Liesel", "Berlin"));
_EselWelt.add(new Esel(40, "Speedy", "Meinz"));
_EselWelt.add(new Esel(50, "Speedy", "Kiel"));
initComponents();
}
Vector<Esel> _EselWelt = new Vector<Esel>();
Vector<Treck> _TreckWelt = new Vector<Treck>();
Vector TV = new Vector();
Vector EV = new Vector();
ArrayList<Integer> tempremovelist = new ArrayList<Integer>();
public Vector<Esel> getEselWelt() {
return _EselWelt;
}
public Vector<Treck> getTreckWelt() {
return _TreckWelt;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
jDialog1 = new javax.swing.JDialog();
jButton1 = new javax.swing.JButton();
jTextField2 = new javax.swing.JTextField();
jSpinner1 = new javax.swing.JSpinner();
jScrollPane3 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
jDialog2 = new javax.swing.JDialog();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jButton8 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jButton4 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jButton10 = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jButton3 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane1 = new javax.swing.JScrollPane();
jList3 = new javax.swing.JList();
jPanel5 = new javax.swing.JPanel();
jScrollPane4 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane5 = new javax.swing.JScrollPane();
maps1 = new edu.gui.Maps();
jDialog1.setTitle("EselTreck v1.0");
jDialog1.setIconImage(null);
jDialog1.setMinimumSize(new java.awt.Dimension(300, 268));
jButton1.setText("ERSTELLEN");
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextField2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField2.setText("NAME");
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jList2.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Kiel", "Hamburg", "Schwerin", "Bremen", "Berlin", "Hannover", "Magdeburg", "Potsdam", "Dresden", "Erfurt", "Düsseldorf", "Wiesbaden", "Mainz", "Saarbrücken", "Stuttgart", "München" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jList2.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane3.setViewportView(jList2);
javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog1Layout.createSequentialGroup()
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
.addContainerGap())
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jDialog2.setMinimumSize(new java.awt.Dimension(330, 180));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("START:");
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setText("ZIEL:");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kiel", "Hamburg", "Schwerin", "Bremen", "Berlin", "Hannover", "Magdeburg", "Potsdam", "Dresden", "Erfurt", "Düsseldorf", "Wiesbaden", "Mainz", "Saarbrücken", "Stuttgart", "München" }));
jComboBox1.setSelectedIndex(1);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kiel", "Hamburg", "Schwerin", "Bremen", "Berlin", "Hannover", "Magdeburg", "Potsdam", "Dresden", "Erfurt", "Düsseldorf", "Wiesbaden", "Mainz", "Saarbrücken", "Stuttgart", "München" }));
jComboBox2.setSelectedIndex(15);
jButton8.setText("CREATE");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
jDialog2.getContentPane().setLayout(jDialog2Layout);
jDialog2Layout.setHorizontalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog2Layout.createSequentialGroup()
.addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, 0, 248, Short.MAX_VALUE)
.addComponent(jComboBox2, 0, 248, Short.MAX_VALUE)))
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))
.addContainerGap())
);
jDialog2Layout.setVerticalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
.addContainerGap())
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton2.setText("next Round");
jButton2.setEnabled(false);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton6.setText("in den Bestand aufnehmen");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jPanel1.setMinimumSize(new java.awt.Dimension(240, 150));
jLabel5.setText("Start:");
jLabel6.setText("Ziel:");
jLabel7.setText("Velocity:");
jLabel8.setText("Verblieben:");
jLabel9.setText("Distanz:");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel10.setText("-");
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel11.setText("-");
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel12.setText("-");
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel13.setText("-");
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel14.setText("-");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel7))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
.addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
.addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(45, 45, 45)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE))))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jLabel14))
.addContainerGap(12, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jLabel15.setFont(new java.awt.Font("Marcelle Script", 0, 48));
jLabel15.setText("Runde:");
jLabel16.setFont(new java.awt.Font("Marcelle Script", 0, 48));
jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel16.setText("0");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(jLabel15))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("TRECK"));
jButton4.setText("beladen");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jButton10.setText("STARTEN");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
.addContainerGap())
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("MENÜ"));
jButton3.setText("neuer Esel");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton7.setText("neuer Treck");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${eselWelt}");
org.jdesktop.swingbinding.JListBinding jListBinding = org.jdesktop.swingbinding.SwingBindings.createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, jList1);
jListBinding.setDetailBinding(org.jdesktop.beansbinding.ELProperty.create("${name} [${pace}] [${standort}]"));
bindingGroup.addBinding(jListBinding);
jScrollPane2.setViewportView(jList1);
jList3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
eLProperty = org.jdesktop.beansbinding.ELProperty.create("${treckWelt}");
jListBinding = org.jdesktop.swingbinding.SwingBindings.createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, jList3);
jListBinding.setDetailBinding(org.jdesktop.beansbinding.ELProperty.create("von ${startOrt} nach ${zielOrt}"));
bindingGroup.addBinding(jListBinding);
jList3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jList3MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jList3);
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("LOG"));
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setFont(new java.awt.Font("Arial", 0, 12));
jTextArea1.setRows(5);
jScrollPane4.setViewportView(jTextArea1);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
.addContainerGap())
);
javax.swing.GroupLayout maps1Layout = new javax.swing.GroupLayout(maps1);
maps1.setLayout(maps1Layout);
maps1Layout.setHorizontalGroup(
maps1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 777, Short.MAX_VALUE)
);
maps1Layout.setVerticalGroup(
maps1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 996, Short.MAX_VALUE)
);
jScrollPane5.setViewportView(maps1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane5, 0, 0, Short.MAX_VALUE))
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)))
.addContainerGap())
);
bindingGroup.bind();
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try {
String eselName = jTextField2.getText();
int eselVelocity = (Integer) jSpinner1.getValue();
String eselStandort = (String) jList2.getSelectedValue();
Esel neuerEsel = new Esel(eselVelocity, eselName, eselStandort);
_EselWelt.add(neuerEsel);
EV.clear();
for (int i = 0; i < _EselWelt.size(); i++) {
EV.add(_EselWelt.get(i).getName() + " [" + _EselWelt.get(i).getPace() + "] [" + _EselWelt.get(i).getStandort() + "]");
}
jList1.setListData(EV);
jDialog1.setVisible(false);
} catch (Exception e) {
jTextArea1.append("ungültige Eingabe!");
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
jDialog1.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField2ActionPerformed
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
String A = (String) jComboBox1.getSelectedItem();
String B = (String) jComboBox2.getSelectedItem();
Treck route = new Treck(A, B);
_TreckWelt.add(route);
jLabel10.setText(route.getStartOrt());
jLabel11.setText(route.getZielOrt());
int distanz = route.getDistanz();
jLabel13.setText(String.valueOf(distanz));
//int aktuelleRunde = Integer.parseInt(jLabel16.getText());
jLabel12.setText(String.valueOf(route.velocity()));
int rest = route.restStrekeBerechnen();
route.setVerblieben(distanz);
jLabel14.setText(String.valueOf(rest));
TV.clear();
for (int i = 0; i < _TreckWelt.size(); i++) {
TV.add("von " + _TreckWelt.get(i).getStartOrt() + " nach " + _TreckWelt.get(i).getZielOrt());
}
jList3.setListData(TV);
maps1.trecklist.add(new Rectangle2D.Float(route.getKoordinate(route.getStartOrt(), "x") - 10, route.getKoordinate(route.getStartOrt(), "y") - 10, 20, 20));
jDialog2.setVisible(false);
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
jDialog2.setVisible(true);
}//GEN-LAST:event_jButton7ActionPerformed
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
if (!_TreckWelt.isEmpty()) {
for (int i = 0; i < _TreckWelt.size(); i++) {
_TreckWelt.get(i).setStarted(true);
}
jButton2.setEnabled(true);
jTextArea1.append("3...2...1... Trecks sind gestartet\n");
jButton3.setEnabled(false);
jButton4.setEnabled(false);
jButton6.setEnabled(false);
jButton7.setEnabled(false);
jTextField1.setEnabled(false);
jButton10.setEnabled(false);
//maps1.repaint();
} else {
jTextArea1.append("Es gibt noch keinen Treck, um ihn auf die Reise zu schicken!\n");
}
}//GEN-LAST:event_jButton10ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// set next round
jLabel16.setText(String.valueOf(Integer.parseInt((jLabel16.getText())) + 1));
drawEselBox();
for (int i = 0; i < _TreckWelt.size(); i++) {
// weise neuer Wert zu
_TreckWelt.get(i).setRunde(Integer.parseInt(jLabel16.getText()));
// Errechne die Reststrecke
_TreckWelt.get(i).setVerblieben(_TreckWelt.get(i).restStrekeBerechnen());
// weise neue Werte zu
if (_TreckWelt.get(i).getVerblieben() <= 0) {
jTextArea1.append("Der Treck ist von " + _TreckWelt.get(i).getStartOrt() + " nach " + _TreckWelt.get(i).getRunde() + " Runden in " + _TreckWelt.get(i).getZielOrt() + " angekommen\n");
// Entlade den Treck
_TreckWelt.get(i).entladen();
// Ändere den Standort des Esels
for (int c = 0; c < _TreckWelt.get(i).getEsel().size(); c++) {
_TreckWelt.get(i).getEsel().get(c).setStandort(_TreckWelt.get(i).getZielOrt());
_TreckWelt.get(i).getEsel().get(c).setStatus(false);
}
// Merke die nummer des Trecks, um ihn später zu löschen
tempremovelist.add(i);
}
updateStatus(jList3.getSelectedIndex());
}
if (!tempremovelist.isEmpty()) {
for (int d = tempremovelist.size() - 1; d >= 0; d--) {
int remIndex = tempremovelist.get(d);
_TreckWelt.remove(remIndex);
tempremovelist.remove(d);
maps1.trecklist.remove(remIndex);
}
EV.clear();
for (int g = 0; g < _EselWelt.size(); g++) {
EV.add(_EselWelt.get(g).getName() + " [" + _EselWelt.get(g).getPace() + "] [" + _EselWelt.get(g).getStandort() + "]");
}
jList1.setListData(EV);
TV.clear();
for (int i = 0; i < _TreckWelt.size(); i++) {
TV.add("von " + _TreckWelt.get(i).getStartOrt() + " nach " + _TreckWelt.get(i).getZielOrt());
}
jList3.setListData(TV);
if (!TV.isEmpty()) {
jList3.setSelectedIndex(0);
}
}
if (_TreckWelt.isEmpty()) {
jButton2.setEnabled(false);
// Aktiviere Buttons
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jTextField1.setEnabled(true);
jButton10.setEnabled(true);
jTextArea1.append("FINISH: Alle Trecks haben ihr Ziel erreicht\n");
}
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
if (!jList3.isSelectionEmpty()) {
try {
int ladung = Integer.parseInt(jTextField1.getText());
_TreckWelt.get(jList3.getSelectedIndex()).addLoad(ladung);
jTextArea1.append("Der Treck wurde um weitere " + ladung + " Gepäckstücke beladener\n");
jLabel12.setText(String.valueOf(_TreckWelt.get(jList3.getSelectedIndex()).velocity()));
} catch (Exception e) {
jTextArea1.append("Geben Sie einen gültigen Wert ein\n");
}
} else {
jTextArea1.append("Der Treck kann nicht beladen werden, da es noch keinen Treck existiert!\n");
}
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
if (!jList1.isSelectionEmpty()) {
if (!jList3.isSelectionEmpty()) {
if (_TreckWelt.get(jList3.getSelectedIndex()).getStartOrt().equals(_EselWelt.get(jList1.getSelectedIndex()).getStandort())) {
if (_EselWelt.get(jList1.getSelectedIndex()).getStatus() == false) {
_TreckWelt.get(jList3.getSelectedIndex()).addEsel(_EselWelt.get(jList1.getSelectedIndex()));
jTextArea1.append(_EselWelt.get(jList1.getSelectedIndex()).getName() + " wurde erfolgreich in den Bestand aufgenohmen\n");
_EselWelt.get(jList1.getSelectedIndex()).setStatus(true);
jLabel12.setText(String.valueOf(_TreckWelt.get(jList3.getSelectedIndex()).velocity()));
} else {
jTextArea1.append(_EselWelt.get(jList1.getSelectedIndex()).getName() + " ist schon in Benutzung\n");
}
} else {
jTextArea1.append(_EselWelt.get(jList1.getSelectedIndex()).getName() + " befindet sich an einem anderen Ort und kann deshalb nicht dem Treck hinzugefügt werden\n");
}
} else {
jTextArea1.append("Wählen Sie einen Treck aus!\n");
}
} else {
jTextArea1.append("Wählen Sie einen Esel aus!\n");
}
}//GEN-LAST:event_jButton6ActionPerformed
private void jList3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList3MouseClicked
if (!jList3.isSelectionEmpty()) {
updateStatus(jList3.getSelectedIndex());
} else {
jTextArea1.append("Es existiert noch keinen Treck!\n");
}
}//GEN-LAST:event_jList3MouseClicked
public double getAngle(double x1, double y1, double x2, double y2) {
double angle = Math.toDegrees(Math.atan2(x1 - x2, y1 - y2));
angle = angle - 180;
if (angle > 360) {
angle = angle - 360;
} else if (angle < 0) {
angle = angle + 360;
}
return angle;
}
public void drawEselBox() {
if (maps1.trecklist.isEmpty()) {
return;
}
for (int i = 0; i < maps1.trecklist.size(); i++) {
int kmh = _TreckWelt.get(i).velocity();
/** Totale berechnung des Winkeals: START*/
//int x1Angle = _TreckWelt.get(i).getKoordinate(_TreckWelt.get(i).getStartOrt(), "x");
//int y1Angle = _TreckWelt.get(i).getKoordinate(_TreckWelt.get(i).getStartOrt(), "y");
double xRect = maps1.trecklist.get(i).getCenterX();
double yRect = maps1.trecklist.get(i).getCenterY();
double x2Angle = _TreckWelt.get(i).getKoordinate(_TreckWelt.get(i).getZielOrt(), "x");
double y2Angle = _TreckWelt.get(i).getKoordinate(_TreckWelt.get(i).getZielOrt(), "y");
//double angle = 90 + Math.atan2(y2Angle - yRect, x2Angle - xRect) * 180 / Math.PI;
double angle = getAngle(xRect, yRect, x2Angle, y2Angle);
/** Totale berechnung des Winkeals: ENDE*/
double X = kmh * Math.sin(Math.toRadians(angle)) * (1) + xRect;
double Y = kmh * Math.cos(Math.toRadians(angle)) * (1) + yRect;
maps1.trecklist.get(i).setRect(X - 10, Y - 10, 20, 20);
}
repaint();
}
private void updateStatus(int i) {
jLabel10.setText(_TreckWelt.get(i).getStartOrt());
jLabel11.setText(_TreckWelt.get(i).getZielOrt());
jLabel12.setText(String.valueOf(_TreckWelt.get(i).velocity()));
jLabel13.setText(String.valueOf(_TreckWelt.get(i).getDistanz()));
jLabel14.setText(String.valueOf(_TreckWelt.get(i).getVerblieben()));
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TreckGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TreckGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TreckGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TreckGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TreckGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JDialog jDialog1;
private javax.swing.JDialog jDialog2;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JList jList1;
private javax.swing.JList jList2;
private javax.swing.JList jList3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private edu.gui.Maps maps1;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables
}